<template>
  <div class="look-from-box">
    <div class="left">
      <el-button icon="el-icon-arrow-left" type="primary" @click="$router.go(-1)">返回</el-button>
      <div class="leftDialog" v-if="fromDetail">
        <div class="item-box">
          <div class="left-title">
            配置编号:
          </div>
          <div class="right">
            {{fromDetail.code}}
          </div>
        </div>
        <div class="item-box">
          <div class="left-title">
            配置标题:
          </div>
          <div class="right">
            {{fromDetail.title}}
          </div>
        </div>
        <div class="item-box">
          <div class="left-title">
            活动主题:
          </div>
          <div class="right">
            {{fromDetail.activityName}}
          </div>
        </div>
        <div class="item-box">
          <div class="left-title">
            活动说明:
          </div>
          <div class="right">
            {{fromDetail.activityDesc}}
          </div>
        </div>
        <div class="item-box">
          <div class="left-title">
            备注:
          </div>
          <div class="right">
            {{fromDetail.remark == "" ? "---":fromDetail.remark}}
          </div>
        </div>
      </div>
    </div>
    <el-divider direction="vertical"></el-divider>
    <div class="right">
      <div v-for="(item,i) in config">
        <p class="PSQtitle">{{i + 1}}/{{config.length}}:  {{ item.name }}</p>
        <div v-if="item.type === 'radio'">
          <a-radio-group>
            <a-radio
              :style="radioStyle"
              :value="index2"
              v-for="(item2, index2) in item.values"
              :key="index2"
              :disabled="false"
            >
              {{ item2.label }}
            </a-radio>
          </a-radio-group>
        </div>
        <div v-if="item.type === 'checkbox'">
          <a-checkbox-group>
            <a-checkbox
              :style="radioStyle"
              :value="index2"
              v-for="(item2, index2) in item.values"
              :key="index2"
              :disabled="false"
            >
              {{ item2.label }}
            </a-checkbox>
          </a-checkbox-group>
        </div>
        <div v-if="item.type === 'text'">
          <el-input
            type="textarea"
            :rows="2"
            disabled
            placeholder="请输入内容">
          </el-input>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {
    configFormDetail
  } from '@/api/getData'
  export default {
    data() {
      return {
        fromDetail: null,
        config:null,
        radioStyle: {
          display: "block",
          height: "30px",
          lineHeight: "30px",
        },
      }
    },
    mounted() {
      this.dataInfo()
    },
    methods: {
      async dataInfo() {
        try {
          let formId = this.$route.query.id;
          const result = await configFormDetail(formId);
          if (result.code == 200) {
            this.fromDetail = result.data;
            this.config = JSON.parse(result.data.config)
            console.log(this.config)
          }
        } catch (err) {
          console.log(err)
        }
      },
    }
  }
</script>

<style scoped lang="scss">
  .look-from-box{
    display: flex;
    height: calc(100vh - 155px);
    .left {
      width: 40%;
      padding: 25px 25px;
      .leftDialog{
        margin-top: 30px;
        box-sizing: border-box;
        .item-box{
          display: flex;
          .left-title{
            font-weight: 800;
          }
        }
      }
    }
    .el-divider--vertical{
      height: calc(100vh - 155px);
    }
    .right{
      padding-left: 16px;
      box-sizing: border-box;
      overflow-y: scroll;
      padding-bottom: 30px;
      width: 60%;
    }
    .right::-webkit-scrollbar{
      width: 0;
    }
  }
  .PSQtitle {
    font-size: 16px;
    font-weight: bold;
    margin-top: 16px;
  }
  .ant-checkbox-wrapper + .ant-checkbox-wrapper{
    margin-left: 0px;
  }
</style>
